<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./js/axios.js"></script>
</head>

<body>
  <button id="btn">点击我get请求</button>
  <button id="btn2">点击我post请求</button>
  <button id="btn3">点击我</button>
  <script>
    let btn = document.querySelector('#btn')
    let btn2 = document.querySelector('#btn2')
    let btn3 = document.querySelector('#btn3')
    // btn.onclick = () => {
    //   axios.get('http://127.0.0.1:3000/demo').then(res => {
    //     console.log(res);
    //   }).catch(err => {
    //     console.log(err);
    //   })
    // }
    btn3.onclick = async function(){
      const a = await axios.get('/a')
      console.log(a);
    }
      btn.onclick = async() => {
        const { data } = await axios.get('/demo', {
          params: {
            pageNum : 1,
            pageSize: 5
          }
        })
        console.log(data)
      }
      btn2.onclick = async() => {
        const { data } = await axios.post('/demo', {
          pageNum : 2,
          pageSize: 6
        })
      }
  </script>
</body>

</html>